

package com.maoshi.shop.mp.comment.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.maoshi.shop.mp.comment.dao.WeixinMenuMapper;
import com.maoshi.shop.mp.comment.model.WeiXinMenu;
import com.maoshi.shop.mp.comment.service.WeixinMenuService;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.mp.api.WxMpMenuService;
import me.chanjar.weixin.mp.api.WxMpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

/**
 *
 * @author lgh on 2019/05/13.
 */
@Service
public class WeixinMenuServiceImpl extends ServiceImpl<WeixinMenuMapper,WeiXinMenu> implements WeixinMenuService {

    @Autowired
    private WeixinMenuMapper weixinMenuMapper;

    @Autowired
    private WxMpService wxMpService;

    @Override
    public void release() throws WxErrorException {
        //获取
        WeiXinMenu weiXinMenu = weixinMenuMapper.selectById(1);
        //对接微信接口发布菜单
        WxMpMenuService menuService = wxMpService.getMenuService();
            menuService.menuDelete();
            menuService.menuCreate(weiXinMenu.getMenu());
    }
}
